package com.qingzhuge.member.dao;

import com.qingzhuge.dao.BasePkLongDao;
import com.qingzhuge.member.entity.SysMember;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

/**
 * @author : zero.xiao
 * @description : 会员
 * @date :2018/6/12 0012 下午 17:22
 * @modified :
 * @since : 1.0.0
 */
public interface SysMemberDao extends BasePkLongDao<SysMember> {
    SysMember findByUsername(String username);
    SysMember findByMobile(String mobile);
    SysMember findByEmail(String email);
    SysMember findByUsernameAndMobile(String username,String mobile);
    SysMember findByUsernameOrMobile(String username,String mobile);
    @Query("select new SysMember(id, name, nickname, mobile, phone, sex, avatar) from SysMember m where m.id = :id")
    SysMember findShortInfo(@Param("id") Long id);

    @Modifying
    @Query("update SysMember m set m.mobile = :mobile where m.id = :id")
    void updateMobile(@Param("id") Long id,@Param("mobile") String mobile);
}
